package com.cyb.myfriend.utils;

import com.cyb.myfriend.constant.BaseResponse;
import com.cyb.myfriend.constant.StatusCode;

/**
 * 返回工具类
 *
 * @author cyb
 * @date 2024/08/12 08:12
 **/
public class ResultUtil {

    /**
     * 成功
     *
     * @param data
     * @return
     */
    public static <T> BaseResponse<T> success(T data) {
        return new BaseResponse<>(StatusCode.SUCCESS.getCode(), data);
    }

    /**
     * 成功
     *
     * @param data
     * @return
     */
    public static <T> BaseResponse<T> success(T data, String message) {
        return new BaseResponse<>(StatusCode.SUCCESS.getCode(), message, data);
    }

    /**
     * 失败
     *
     * @param code
     * @param data
     * @param message
     * @return
     * @param <T>
     */
    public static <T> BaseResponse<T> fail(int code, T data, String message) {
        return new BaseResponse<>(code, message, data);
    }

    public static <T> BaseResponse<T> fail(int code, String message) {
        return new BaseResponse<>(code, message);
    }

    public static <T> BaseResponse<T> fail(int code, T data) {
        return new BaseResponse<>(code, data);
    }
}

